#ifndef PICTURE_H
#define PICTURE_H

#include "sizehandle.h"

#include <QObject>
#include <QRect>
#include <QPainter>
#include <QList>

class SizeHandle;

class PicturePrivate
{
public:
    PicturePrivate();
public:
    QRect m_moveRect;
    QRect m_Rect;
    QRect m_parentRect;
    QList<SizeHandle> m_sizeHandleList;
};

class Picture : public QObject
{
    Q_OBJECT
public:
    explicit Picture(QObject *parent = nullptr);
    QRect rect() const;
    void setRect(QRect rect);
    void setRect(const QPoint &topLeft, const QSize &size);
    void setSize(const QSize &size);
    void paint(QPainter *painter);
    uint frameWidth() const;
    void updateHandle();
    QRect adjusted() const;
    QPoint move(const QPoint &pt);
    QPoint resize(int dir, const QPoint &pts);
    void setParentWidgetRect(const QRect& rect)
    {
        d_ptr->m_parentRect = rect;
    }

    QPoint topLeft() const;
    QPoint topCenter() const;
    QPoint topRight() const;
    QPoint rightCenter() const;
    QPoint bottomRight() const;
    QPoint bottomCenter() const;
    QPoint bottomLeft() const;
    QPoint leftCenter() const;

    int detectCursor(const QPoint &pt, int &dir) const;
signals:

private:
    //返回锚点序号
    int inDirectionSize(const QPoint &pt) const;
    void init();
private:
    PicturePrivate *d_ptr;
};

#endif // PICTURE_H
